<div class="widget our-agents">
    <div class="title">
        <h2 class="block-title">Контакты</h2>
    </div><!-- /.title -->

    <div class="content">
        <div class="box agent">
            <div class="name"><?= $user->profile->firstname; ?></div><!-- /.name -->
            <div class="phone"><?= $user->profile->mobile; ?></div>
            <div class="email"><a href="mailto:<?= $user->email; ?>"><?= $user->email; ?></a></div>
        </div>
    </div><!-- /.content -->
</div><!-- /.our-agents -->

<?php if (1) { ?>
    <div class="widget contact">
        <div class="title">
            <h2 class="block-title">Личное сообщение</h2>
        </div><!-- /.title -->

        <div class="content">
            <?php if ($model->is_send_mail) { ?>
                <div class="alert alert-success" style="margin: 0px;w">
<!--                    <button type="button" class="close" data-dismiss="alert">×</button>-->
                        Сообщение отправленно!
                </div>
            <?php } else { ?>
            
                <?php
                $form = $this->beginWidget('CActiveForm', array(
                    'id' => 'private-essage-agent-form',
                    'enableClientValidation' => true,
                    'clientOptions' => array(
                        'validateOnSubmit' => true,
                    ),
                    'htmlOptions' => array(
                        'class' => 'contact-form'
                    ),
                ));
                ?>


                <?php if ($model->getErrors()) { ?> 
                    <div class="alert alert-error">
                        <button type="button" class="close" data-dismiss="alert">×</button>
                        <?php echo $form->errorSummary(array($model)); ?>
                    </div>
                <?php }; ?>

                <?php echo $form->hiddenField($model, 'user_id' , array('value'=> $user->id)); ?>
                <?php echo $form->hiddenField($model, 'flat_id' , array('value'=> $flat->id)); ?>
            
                <?php $field = 'name'; ?>
                <div class="control-group">
                    <label class="control-label" for="inputName">
                        <?php echo strip_tags($form->label($model, $field)); ?>
                        <span class="form-required" title="This field is required.">*</span>
                    </label>
                    <div class="controls">
                        <?php echo $form->textField($model, $field, array(
                            'placeholder' => 'Ваша имя',
                            'pattern' => '^([А-ЯЁ]{1})([а-яё]{1,20})$',
                            )) ?>
                    </div><!-- /.controls -->
                </div><!-- /.control-group -->

                <?php $field = 'email'; ?>
                <div class="control-group">
                    <label class="control-label" for="inputEmail">
                        <?php echo strip_tags($form->label($model, $field)); ?>
                        <span class="form-required" title="This field is required.">*</span>
                    </label>
                    <div class="controls">
                        <?php echo $form->textField($model, $field, array(
                            'placeholder' => 'Ваша электронная почта',
                            'pattern' => '^[a-zA-Z0-9_\-.]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-.]+$'
                            )) ?>
                    </div><!-- /.controls -->
                </div><!-- /.control-group -->

                <?php $field = 'phone'; ?>
                <div class="control-group">
                    <label class="control-label" for="inputPhone">
                        <?php echo strip_tags($form->label($model, $field)); ?>
                        <span class="form-required" title="This field is required.">*</span>
                    </label>
                    <div class="controls">
                        <?php echo $form->textField($model, $field, array(
                            'placeholder' => 'Ваш телефон',
                            'pattern' => '^([\+])??([0-9]){8,12}$',
                            'minlength' => 10,
                            )) ?>
                    </div><!-- /.controls -->
                </div><!-- /.control-group -->

                <?php $field = 'message'; ?>
                <div class="control-group">
                    <label class="control-label" for="inputPhone">
                        <?php echo strip_tags($form->label($model, $field)); ?>
                        <span class="form-required" title="This field is required.">*</span>
                    </label>
                    <div class="controls">
                        <?php echo $form->textArea($model, $field, array('placeholder' => 'Ваше сообщение')); ?>
                    </div><!-- /.controls -->
                </div><!-- /.control-group -->

                <div class="form-actions">
                    <?php echo CHtml::submitButton('Отправить', array('class' => 'btn btn-primary arrow-right')); ?>
                </div><!-- /.form-actions -->
                <?php $this->endWidget(); ?>
            <?php } ?>
        </div><!-- /.content -->
    </div><!-- /.widget -->

<?php } ?>